<?php

/**
* PDFTest.php
*
* Test PDF generation
*
* @author     Blazej Zieba <b@zieba.info>
* @copyright  2007 konekto.com
* @version    CVS: $Id:$
*/
require_once '../framework/config.php';

require_once 'simpletest/autorun.php';

require_once '../PDF.class.php';


class  PDFTest extends UnitTestCase
{

    public function setUp() 
    {
        $this->content = array();
        for($i=0; $i < 100 ; $i++ )
        {
            $this->content[] = array( 
            'guide_id' => 'guide_id'.$i,
            'slide_id' => 'slide_id'.$i,
            'title' => 'title'.$i,
            'subTitle' => 'subTitle'.$i,
            'desc' => 'desc'.$i);
        }

        $upload = &PEAR::getStaticProperty('CONFIG_INI','UPLOAD');

        $path =$upload['upload_dir'];

        $this->assertNotEqual($path, '', 'Upload dir not set');


        $this->fileName = $path."/".md5(uniqid(rand(), true)).".pdf";

        $this->pdf = new PDF();

        $this->pdf->setContent($this->content);

        $this->pdf->createPage();
    }

    public function testCreatePDF()
    {
        $this->pdf->Output($this->fileName,'F');
        $this->assertEqual( hash_file('md5','pattern.pdf') ,  hash_file('md5',$this->fileName), 'Hash not equal. Comment fpfd CreationData.');
    }



    public function tearDown() 
    {

        $this->assertTrue( unlink( $this->fileName ), 'Could not remove file'.$this->fileName );
       
    }
 

}
?>
